﻿@model CmsEntityMetaInformation

@{
    string controllerName = ViewBag.ControllerName.ToLower();
}

<div class="properties t-content-inner g-clear">
    <p>
        <a class="add-property b-button" href="@Url.Action("addproperty", @controllerName)">Add new</a>        
    </p>    
	<fieldset class="b-form hide">
		<ol class="b-form__rows ul-reset g-clear">            	                        
        	<li class="b-form__row g-clear">
		        <label for="propertyName">Property name:</label>
		        <input id="propertyName" class="property-name text" name="propertyName" type="text" value="" /> 
            </li>
            <li class="b-form__row g-clear">
                <label for="propertyValue">Property value:</label>
		        <input id="propertyValue" class="property-value text" name="propertyValue" type="text" value="" /> 
            </li>
            <li class="b-form__row g-clear">
                <input id="propertyId" class="property-id" name="propertyId" type="hidden" value="@Model.Id" />
                <input class="property-action-url" type="hidden" />
		        <input class="save-property b-button b-button_small" type="submit" value="Save" />         		
                <a class="cancel-property b-button b-button_small b-button_colour_grey">Cancel</a>
        	</li>
        </ol>		
	</fieldset>      
    @(Html.Telerik().Grid(Model.Metas).HtmlAttributes(new { style = "width:300px;" })
        .Name("EntityPropertyGrid")
        .Columns(columns =>
                    {
                        columns.Bound(p => p.MetaFieldName).Title("Property name");
                        columns.Bound(p => p.EntityMetaValue).Title("Property value");
                        columns.Template(
                            @<text>
                                <a href="@Url.Action("editproperty", @controllerName, new { id = Model.Id })" class="edit-property b-icon b-icon_edit" title="Edit">Edit</a>                                
                            </text>)
                        .ClientTemplate("<a href=" + Url.Action("editproperty", @controllerName) + "/<#= Model.Id#> class='edit-property b-icon b-icon_edit' title='Edit'>Edit</a>")
                        .Title("Edit");
                        columns.Template(
                            @<text>
                                <a href="@Url.Action("deleteproperty", @controllerName, new { id = Model.Id })" title="Property" class="b-icon b-icon_delete"/>
                            </text>
                            )
                        .ClientTemplate("<a href=" + Url.Action("deleteproperty", @controllerName) + "/<#= Model.Id#> class='delete-property b-icon b-icon_delete' title='Property'>Delete</a>")
                        .Title("Delete");
                    })
                    .DataBinding(dataBinding => dataBinding.Ajax().Select("_entityproperty", @controllerName, new { id = Model.Id }))
    )
</div>